<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:head>
</h:head>
<h:body>
	<h:outputStylesheet name="traveldream.css" />
	<h:form id="form">
		<p:panelGrid>
			<p:row>
				<p:column>
					<p:panelGrid style="width: 100%" cellpadding="3" id="meanPanel">
						<f:facet name="header">
							<p:row>
								<p:column colspan="2">
									<p:outputLabel value="Transport mean" />
								</p:column>
							</p:row>
						</f:facet>
						<p:row>
							<p:column colspan="2">
								<p:outputLabel id="meanName" style="align: center;"
									value="#{reservationBean.selectedMean.name}" />
							</p:column>
						</p:row>

						<p:row>
							<p:column>
								<p:outputLabel for="meanPrice" value="Prezzo: " />
							</p:column>
							<p:column>
								<p:outputLabel id="meanPrice"
									value="#{reservationBean.selectedMean.price}" />
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<p:outputLabel for="meanDeparture" value="Partenza: " />
							</p:column>
							<p:column>
								<p:outputLabel
									value="#{reservationBean.selectedMean.departure.name}"
									id="meanDeparture" />
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<p:outputLabel for="meanQuantity" value="Booking for: " />
							</p:column>
							<p:column>
								<p:outputLabel id="meanQuantity"
									value="#{reservationBean.travellers}" />
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<p:outputLabel value="Leaving:" />
							</p:column>
							<p:column>
								<h:outputText value="#{reservationBean.leavingDate}">
									<f:convertDateTime pattern="EEE, dd MMM yyyy" />
								</h:outputText>
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<p:outputLabel value="Coming back:" />
							</p:column>
							<p:column>
								<h:outputText value="#{reservationBean.endDate}">
									<f:convertDateTime pattern="EEE, dd MMM yyyy" />
								</h:outputText>
							</p:column>
						</p:row>
					</p:panelGrid>
				</p:column>
				<p:column>
					<p:panelGrid columns="2" cellpadding="3" id="hotelPanel"
						width="100%">
						<f:facet name="header">
							<p:row>
								<p:column colspan="2">
									<p:outputLabel value="Hotel" />
								</p:column>
							</p:row>
						</f:facet>
						<p:row>
							<p:column rowspan="2">
								<p:outputLabel id="hotelName"
									value="#{reservationBean.selectedHotel.name}" />
							</p:column>
						</p:row>
						<p:dataList value="#{reservationSummaryBean.chosenRooms}" var="r"
							itemType="circle">
						<p:outputLabel> 
	    					Quantity #{r.type.toString()}: #{r.selectedRooms}/#{r.totalRooms}, at #{r.price.toPlainString()} € 
						</p:outputLabel> 
			</p:dataList>
					</p:panelGrid>
				</p:column>
			</p:row>
			<p:row>
				<p:column>
					<p:dataList style="width: 100%" styleClass="borderLess"
						id="excursionList" value="#{reservationBean.selectedExs}" var="ex"
						itemType="circle">
						<f:facet name="header">
							<p:outputLabel value="Excursions" />
						</f:facet>
	    	#{ex.name}, #{ex.weekDay.toString()} 
			</p:dataList>
				</p:column>
				<p:column>
					<p:outputLabel id="price"
						value="Total price: #{reservationSummaryBean.price.toPlainString()} €" />
				</p:column>
			</p:row>
		</p:panelGrid>

		<p:panelGrid cellpadding="5" id="bookPanel">
			<f:facet name="header">
				<p:row>
					<p:column colspan="3">
	        You are almost travelling!
	        </p:column>
				</p:row>
			</f:facet>

			<p:row rendered="#{reservationSummaryBean.discountAvailable}">
				<p:column>
					<p:outputLabel value="Ehi! You've got a discount ticket available" />
				</p:column>
				<p:column>Do you want to use it? This will refresh total price</p:column>
				<p:column>
					<p:selectBooleanCheckbox id="discountCheckBox"
						value="#{reservationSummaryBean.useDiscount}">
						<p:ajax update="form:price"
							listener="#{reservationSummaryBean.toggleDiscount}" />
					</p:selectBooleanCheckbox>
				</p:column>
			</p:row>
			<p:row>
				<p:column>
					<p:outputLabel for="friendMail"
						value="Invite a friend! Email address:" />
				</p:column>
				<p:column colspan="2">
					<p:inputText value="#{reservationSummaryBean.friendMail}"
						id="friendMail" />
				</p:column>
			</p:row>
			<f:facet name="footer">
				<p:row>
					<p:column colspan="3">
						<p:commandButton update=":form" id="bookButton"
							value="Book travel" icon="ui-icon-check"
							action="#{reservationSummaryBean.book()}" />
					</p:column>
				</p:row>
			</f:facet>
		</p:panelGrid>

		<h:outputLabel id="errorLabel"
			rendered="#{not empty reservationSummaryBean.error}"
			value="#{reservationSummaryBean.error}" style="color:red" />
	</h:form>
</h:body>
</html>